import request from '@/utils/request'

// 获取菜单树
export function getMenuTree() {
  return request({
    url: '/menu/tree',
    method: 'get'
  })
}

// 根据父节点ID获取菜单列表
export function getMenuListByParent(parentId) {
  return request({
    url: '/menu/list',
    method: 'get',
    params: { parentId }
  })
}

export function getMenuList(params) {
  return request({
    url: '/menu/tree',
    method: 'get',
    params
  })
}

export function addMenu(data) {
  return request({
    url: '/menu/add',
    method: 'post',
    data
  })
}

export function updateMenu(data) {
  return request({
    url: '/menu/update',
    method: 'post',
    data
  })
}

export function deleteMenu(id) {
  return request({
    url: '/menu/delete',
    method: 'post',
    data: { id }
  })
}

export function fetchMenuList() {
  return request({
    url: '/menu/tree', // 根据你的后端接口实际路径调整
    method: 'get'
  })
} 